home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / FAQSYS18.ZIP / FAQS.DAT / SERPORT.18 / text0000.txt < prev    next >
Encoding:
Text File  |  1995-12-12  |  45.5 KB  |  1,012 lines

  1. Date of release: 22 Feb 1995             Release 18
  2.  
  3. This is a summary on serial communication using the TTY protocol. It
  4. contains information on the TTY protocol and hardware and software implemen-
  5. tations for IBM PCs which has been derived from National Semiconductor data
  6. sheets and practical experience of the author and his supporters. Starting
  7. with release 5, some information on modems has been added.
  8.  
  9. If you want to contribute to this file in any way, please email me (probably
  10. just reply to this posting). My email address is: chbl@stud.uni-sb.de or
  11. chris@phil.uni-sb.de. See the end for details.
  12.  
  13. It's the seventeenth publication of this file. Some errors have been corrected
  14. and some information has been added (which has surely brought other errors
  15. with it, see Murphy's Law).
  16.  
  17. [] brackets often indicate comments to sneaked material; copied lines are
  18. indented. I've made great efforts to always mention who's to be credited.
  19. Please tell me if you find something that you've written that's not correctly
  20. associated with your name.
  21.  
  22. This compilation of information is (C) Copyright 1993 - 1995 by Christian
  23. Blum; all rights reserved. This file is not to be reproduced commercially,
  24. not even partially, without written permission. You are allowed to use it
  25. in any other way you like. I don't want any (monetary) profit being drawn
  26. out of it (neither by me nor by others! I don't mind if you have a look
  27. or two at it at work though... :-). Please feel free to provide this file
  28. to others for free or at your own expenses.
  29.  
  30.  
  31. Changes since the last publication
  32. ==================================
  33.  
  34. Used more proper interrupt acknowledging in the examples (namely the
  35. method I suggested some chapters before :) in order to avoid lock-ups
  36. on MCA computers. (Thanks, Erik)
  37.  
  38. Added some info on the auto flow-control feature of the TL16C550C.
  39. (Thanks, naddy)
  40.  
  41.  
  42. What I'm doing
  43. ==============
  44.  
  45. I'm no longer very much into DOS (though I still make some money with it :),
  46. so don't expect me reading all the groups regularly that I'm posting this
  47. to.
  48.  
  49.  
  50. What others are doing
  51. =====================
  52.  
  53. There is a file available from ftp.phil.uni-sb.de, pub/staff/chris called
  54. The_Serial_Port.more05 that contains an article by Bob Niland covering
  55. serial communication under Windows. It is regularly posted to
  56. comp.sys.ibm.pc.hardware.comm and other groups; if you obtain it from
  57. there it's probably more up to date.
  58.  
  59.  
  60. No more "Automatic File Delivery" (AFD) service
  61. ===============================================
  62.  
  63. The automatic mail reply service I've mentioned in earlier releases of
  64. this file is still available, but I won't do anything to keep it
  65. alive from now on. Please obtain the files via anonymous ftp from
  66. ftp.phil.uni-sb.de (134.96.80.220), pub/staff/chris.
  67.  
  68. If you don't have access to ftp, try using an ftp to email gateway
  69. (ftpmail@decwrl.dec.com or bitftp@pucc.princeton.edu, and probably
  70. a lot more; put 'help' in the body to obtain instructions). If everything
  71. fails, write to me.
  72.  
  73.  
  74. Acknowledgements   (quite a bunch of people by now...)
  75. ================
  76.  
  77. The following persons have contributed (directly or indirectly :-) to this
  78. summary by providing information or making suggestions/reporting errors.
  79. Tell me if your name is missing.
  80.  
  81.       Madis Kaal <mast@anubis.kbfi.ee>
  82.       Steve Poulsen <stevep@ims.com>
  83.       Scott C. Sadow <NS16550A@mycro.UUCP>
  84.       Dan Norstedt <?>
  85.       Alan J. Brumbaugh <brumba@maize.rtsg.mot.com>
  86.       Mike Surikov <surikov@adonis.iasnet.com>
  87.       Varol Kaptan <E66964%trmetu.bitnet@relay.EU.net>
  88.       Richard F. Drushel <rfd@po.CWRU.Edu>
  89.       John A. Limpert <johnl@n3dmc.svr.md.us>
  90.       Brent Beach <ub359@freenet.victoria.bc.ca>
  91.       Torbjoern (sp?) Lindgren <tl@etek.chalmers.se>
  92.       Stephen Warner <ee_d316@dcs.kingston.ac.uk>
  93.       Kristian Koehntopp <kris@black.toppoint.de>
  94.       Angelo Haritsis <ah@doc.ic.ac.uk>
  95.       Jim Graham <jim@n5ial.mythical.com>
  96.       Ralf Brown <ralf@cs.cmu.edu>
  97.       Alfred Arnold <zam036@zam112.zam.kfa-juelich.de>
  98.       Andrew M. Langmead <aml@world.std.com>
  99.       Richard Clayton <richard@locomotive.com>
  100.       Christof Baumgaertner <baumg@rhrk.uni-kl.de>
  101.       Goran Bostrom <GORAN@infovox.se>
  102.       Brian Mork <bmork@opus-ovh.spk.wa.us>
  103.       Richard Steven Walz <rstevew@armory.com>
  104.       Scott David Daniels <daniels@cse.ogi.edu>
  105.       Brian Onn <Brian.Onn@Canada.Sun.COM>
  106.       Erik Suurmaa <erik@lerdeil.ee>
  107.       Terence Edwards <Terence@tedwards.demon.co.uk>
  108.       Christian 'naddy' Weisgerber <naddy@mips.pfalz.de>
  109.  
  110.  
  111.  
  112. Introduction
  113. ============
  114.  
  115. One of the most universal parts of the PC (except for the CPU, of course :-)
  116. is its serial port. You can connect a mouse, a modem, a printer, a plotter,
  117. another PC, dongles :) ...
  118.  
  119. But its usage (both software and hardware) is one of the best-kept secrets
  120. for most users, besides that it is not difficult to understand how to
  121. connect (not plug in) devices to it and how to program it.
  122.  
  123. Regard this file as a manual for the serial port of your PC for both
  124. hardware and software.
  125.  
  126.  
  127. Historical summary
  128. ------------------
  129.  
  130. In early days of telecommunication, errand-boys and optical signals (flags,
  131. lights, clouds of smoke) were the only methods of transmitting information
  132. across long distances. With increasing requirements on speed and growing
  133. amount of information, more practical methods were developed. One milestone
  134. was the first wire-bound transmission on May 24th, 1844 ("What hath God
  135. wrought", using the famous Morse alphabet). Well, technology improved a bit,
  136. and soon there were machines that could be used like typewriters, except that
  137. you typed not only on your own sheet of paper but also on somebody elses.
  138. The only thing that has changed on the step from the teletype to your PC
  139. regarding serial communications is speed.
  140.  
  141.  
  142. The TTY (teletyping) protocol
  143. -----------------------------
  144.  
  145. Definition: A protocol is a clear description of the LOGICAL method of
  146. transmitting information. This does NOT include physical realization.
  147.  
  148. There is a difference between bits per second and baud (named after J. M. E.
  149. Baudot, one of those guys who gave a real push to teletyping): 'baud' means
  150. 'state changes of the line per second' while 'bits per second' ...
  151. well, bits per second means bits per second. You may find this a bit weird
  152. because the numbers are often the same; there's only a difference if the
  153. line has more than two states. Since this is not the case with the RS-232C
  154. (EIA-232) port of your PC, most people don't differentiate between 'baud' and
  155. 'bits per second', while I do. For your convenience, I've replaced baud with
  156. bps even in copied material without special notice. Where you still find baud,
  157. it should read bps in most cases (I didn't change labels in source codes, pin
  158. names in data sheet information etc.). To illustrate the difference I give you
  159. some figures: 2400 bps at 8n1 carry 1920 bits of information per second, and
  160. modems send them at 600 baud thru' the phone wires using eight line states,
  161. while 1200 bps at 7e1 carry 840 bits of information per second that modems
  162. send at 600 baud using four different line states. I know it's confusing...
  163. that's why I quote this from a letter I received from Brent Beach. He explained
  164. it more clearly than I did (I've added some information):
  165.  
  166.   Perhaps a small diagram might help, showing the relationship among the
  167.   players:
  168.  
  169.                                     [bps]             [baud]
  170.      CPU Data              Serial                               Phone
  171.      Bus      -- bytes --> Port  -- bits --> Modem -- tones --> line --
  172.                                                                       |
  173.                                                                       |
  174.      CPU Data              Serial                                     |
  175.      Bus      <-- bytes -- Port  <-- bits -- Modem <-- tones ----------
  176.                    (1)               (2)               (3)
  177.  
  178.   The serial port accepts bytes from the CPU data bus and passes bits to the
  179.   modem. In doing this, the serial port can add or delete bits, depending on
  180.   the coding scheme in use.
  181.  
  182.   At (1) we are concerned with bytes per second. At (2) we are concerned with
  183.   bits per second, and at (3) it's baud. We distinguish because the number of
  184.   bits at (2) need not be equal to the number of bits (that is, bytes times 8)
  185.   at (1), and the number of state changes at (3) is not necessarily the same
  186.   as the number of bits before.
  187.   Bits can be stripped going from (1) to (2): the serial port may transmit
  188.   only 6 or 7 of the 8 bits in the byte. Bits can be added going from (1) to
  189.   (2): the serial port can add a parity bit and stop bits. From (2) to (3),
  190.   bits may be clustered to groups that are transmitted using different
  191.   encoding schemes like 'Frequency Shift Keying' or 'Quadrature Amplitude
  192.   Modulation', to name some.
  193.  
  194.   You can determine the transfer rate in bytes per second depending on the
  195.   serial port speed and the coding system. For example,
  196.  
  197.      8n1: 1 start bit + 8 data bits + 1 stop bit = 10 bits per word.
  198.           At 2400 bps, this is 240 bytes/characters per second. 2400 bps are
  199.           normally transmitted using QAM ('Quadrature Amplitude Modulation')
  200.           where 4 bits are clustered, and hence encoded to 600 baud.
  201.  
  202.      7e1: 1 start bit, 7 data bits, 1 even parity bit, 1 stop bit = 10 bits
  203.           per word. At 1200 bps, this is 120 bytes/characters per second. 1200
  204.           bps are encoded using DPSK ('Differential Phase Shift Keying', two
  205.           bits are clustered), and this results again in 600 baud.
  206.  
  207.  
  208. Now let's leave modems for a while and have a look at the serial port itself.
  209.  
  210. The TTY protocol uses two different line states called 'mark' and 'space'.
  211. (For the sake of clearness I name the line states 'high' (voltage) for
  212. positive and 'low' (voltage) for negative voltages). If no data is
  213. transmitted, the line is in its quiescent 'low' ('mark') state or in the
  214. 'break' state ('high'). Data looks like
  215.  
  216.       space            +---+       +---+   +---+         high  '0' +12V
  217.                        |   |       |   |   |   |
  218.       mark   ----------+   +-------+   +---+   +-------  low   '1' -12V
  219.  
  220.                         (1)  --------(2)-------- (3)
  221.  
  222.   (1) start bit   (2) data bits   (3) stop bit(s)
  223.  
  224. Steve Walz reported that in most (all?) books these kind of diagrams are drewn
  225. the other way round (I just copied what I saw on the oscilloscope) and
  226. that he'd use the labels 'high' and 'low' the other way round, corresponding
  227. to the signals on the TTL level (a matter of taste I guess); here is what he
  228. told me:
  229.  
  230.   In American texts, we will expect to see the data frame for serial transfer
  231.   of all kinds represented, despite the method of transfer (RS-232C, RS-422,
  232.   and optical even), as being an interruption of a normally HI state, and we
  233.   expect to see the diagram you drew in the older release 8, but with the 
  234.   labelling corrected as I have indicated:
  235.  
  236.          mark  ----------+   +-------+   +---+   +-------  high  '1' -12V
  237.              logical  1  | S | 1   1 | 0 | 1 | 0 | Stop
  238.         space            +---+       +---+   +---+         low   '0' +12V
  239.                           (1) --------(2)---------(3)
  240.                  (1) start bit   (2) data bits   (3) stop bit(s)
  241.   Thus transmitting the bit stream 01011, which is LSB first, MSB last.
  242.  
  243.   Indeed it seems to us that a zero SHOULD be the quiescent state, and the
  244.   one an active state, but the first teletypes used a current loop to
  245.   continuously monitor the state of the line, and thus current flow was
  246.   regarded as a 1 and it is "MARK" -ing time, and a signal then left a "SPACE"
  247.   in the graph of current flow designating a zero. Thus the bits following
  248.   the start bit at level zero were true to their bit values, and a 11111 in
  249.   5 bit baudot looked like this, using three dashes per bit:
  250.  
  251.    mark   ------   ------------------------ 1  HI  +5V TTL  -12V RS-232C
  252.   space         ---                         0  LO   0V TTL  +12V RS-232C
  253.                  s  1  1  1  1  1  stop
  254.  
  255.   and the baudot 10101 would appear thus:
  256.  
  257.    mark   ------   ---   ---   ------------ 1  HI  +5V TTL  -12V RS-232C
  258.   space         ---   ---   ---             0  LO   0V TTL  +12V RS-232C
  259.                  s  1  0  1  0  1  stop
  260.  
  261.   and the baudot 01010 would appear thus:
  262.  
  263.    mark   ------      ---   ---   --------- 1  HI  +5V TTL  -12V RS-232C 
  264.   space         ------   ---   ---          0  LO   0V TTL  +12V RS-232C
  265.                  s  0  1  0  1  0  stop
  266.  
  267.   and finally baudot 00000 would appear:
  268.  
  269.    mark   ------                  --------- 1  HI  +5V TTL  -12V RS-232C
  270.   space         ------------------          0  LO   0V TTL  +12V RS-232C
  271.                  s  0  0  0  0  0  stop
  272.  
  273.   Now I know that we don't send five bit baudot over RS-232C now, but I
  274.   wasn't about to try 8 bits, if you don't mind! :)
  275.  
  276.   I know that people get confused about the proper way to draw these, since
  277.   we use inverted voltages to send them via RS-232C interface now, but they
  278.   are still called logical "1" and "mark" when it is really -12 Volts DC, and
  279.   it is called "0" and "space" when it is +12 Volts. And logical one or "mark"
  280.   corresponds to +5 Volts, while logical zero is "space" and corresponds to 0
  281.   Volts. It is this way both within the parallel bus of the computer or the
  282.   transmit output of a UART/USART, with the exception that this data frame is
  283.   terminated by remaining logic "1" or "mark" as a stop bit and preface
  284.   to the next data frame.
  285.  
  286. Both transmitter (TX) and receiver (RX) use the same data rate (measured
  287. in bps, see above), which is the reciprocal value of the smallest time
  288. interval between two changes of the line state. TX and RX know about the
  289. number of data bits (probably with a parity bit added), and both know about
  290. the (minimum!) size of the stop step (called the stop bit or the stop bits,
  291. depending on the size of the stop step; normally 1, 1.5 or 2 times the size
  292. of a data bit). Data is transmitted bit-synchronously and word-asynchronously,
  293. which means that the size of the bits, the length of the words etc.pp. is
  294. clearly defined while the time between two words is undefined.
  295.  
  296. The start bit indicates the beginning of a new data word (this means one
  297. single character). It is used to synchronize transmitter and receiver and
  298. is always a logical '0' (so the line goes 'high' or 'space').
  299.  
  300. Data is transmitted LSB to MSB, which means that the least significant
  301. bit (LSB, Bit 0) is transmitted first with 4 to 7 bits of data following,
  302. resulting in 5 to 8 bits of data. A logical '0' is transmitted by the
  303. 'space' state of the line (+12V), a logical '1' by 'mark' (-12V).
  304.  
  305. A parity bit can be added to the data bits to allow error detection.
  306. There are two (well, actually five) kinds of parity: odd and even (plus
  307. none, mark and space). Odd parity means that the number of 'low' or 'mark'
  308. steps in the data word (including an optional parity bit, but not the
  309. framing bits) is always odd, so the parity bit is set accordingly (I don't
  310. have to explain 'even' parity, must I?). It is also possible to set the
  311. parity bit to a fixed state or to omit it. See Registers section for
  312. details on types of parity.
  313.  
  314. The stop bit does not indicate the end of the word (as it could be derived
  315. >from its name); it rather separates two consecutive words by putting the
  316. line into the quiescent state for a minimum time (that means the stop bit
  317. is a logical '1' or 'mark') in order for the next start bit to be clearly
  318. visible.
  319.  
  320. The framing protocol is usually described by a sequence of numbers and
  321. letters, eg. 8n1 means 1 start bit (always the same, thus omitted), 8 bits
  322. of data, no parity bit, 1 stop bit. 7e2 would indicate 7 bits of data,
  323. even parity, 2 stop bits (but I've never seen this one...). The usual thing
  324. is 8n1 or 7e1.
  325.  
  326. Your PC is capable of serial transmission at up to 115,200 bps (step size
  327. of 8.68 microseconds!). Typical rates are 300 bps, 1200 bps, 2400 bps and
  328. 9600 bps, with 19200 bps, 38400 bps and 57600 bps becoming more and more
  329. popular with high speed modems. Note that some serial ports have difficulties
  330. with high speeds! I've seen PS/2's failing to operate at more than 38400 bps!
  331. How come that IBM machines are often the least IBM compatible? :-)
  332.  
  333. This is what John A. Limpert told me about teletypes:
  334.  
  335.   Real (mechanical) teletypes used 1 start bit, 5 data bits and 1.42 stop
  336.   bits.  Support for 1.5 stop bits in UARTs was a compromise to make the
  337.   UART timing simpler.  Normal speeds were 60 WPM (word per minute),
  338.   66 WPM, 75 WPM and 100 WPM.  A word was defined as 6.1 characters.
  339.   The odd stop bit size was a result of the mechanical nature of the
  340.   machine.  It was the time that the printer needed to finish the current
  341.   character and get ready for the next character.  Most teletypes used
  342.   a 60 mA loop with a 130 V battery.  20 mA loops and lower battery voltages
  343.   became common when 8 level ASCII teletypes were introduced.  The typical
  344.   ASCII teletype ran at 110 bps with 2 stop bits (11 bits per character).
  345.  
  346. It's surely more exact than what I wrote in previous releases. I've just got
  347. to add that at least in Germany 50 bps was a familiar speed. And I think the
  348. lower battery voltage he's talking about was 24 volts.
  349.  
  350.  
  351. The physical transmission
  352. -------------------------
  353.  
  354. Teletypes used a closed-loop line with a quiescent current of 20ma and a
  355. space current of 0ma (typically), which allows to detect a 'broken line'
  356. (hence the name of the 'break' flag, see the Registers section). The RS-232C
  357. port of your PC uses voltages rather than currents to indicate logical states:
  358. 'mark'/'low' is signaled by -3v to -15v (typically -12V) and represents a
  359. logical '1', 'space'/'high' is signaled by +3v to +15v (typically +12V) and
  360. represents a logical '0'. The typical output impedance of the serial port of
  361. a PC is 2 kiloohms (resulting in about 5ma @ 10v), the typical input impedance
  362. is about 4.3 kiloohms, so there should be a maximum fan-out of 5 (5 inputs can
  363. be connected to 1 output). Please don't rely on this, it may differ from PC
  364. to PC.
  365.  
  366. Three lines (RX, TX & ground) are at least needed to make up a bidirectional
  367. connection.
  368.  
  369. Q. Why does my PC have a 25pin/9pin connector if there are only 3 lines
  370.    needed?
  371. A. There are several status lines that are only used with modems etc. See the
  372.    Hardware section and the Registers section of this file.
  373.  
  374. Q. How can I easily connect two PCs by a three-wire lead?
  375. A. Connect RX1 to TX2 and vice versa, GND1 to GND2. In addition to this,
  376.    connect RTS to CTS & DCD and connect DTR to DSR at each end (modem software
  377.    often relies on that). See the hardware section for further details.
  378.  
  379. Please be aware that at 115,200 bps (ie. ca. 115 kHz, but we need the
  380. harmonics up to at least 806 kHz) lines can no longer be regarded as 'ideal'
  381. transmission lines. They are low-pass filters and tend to reflect and mutilate
  382. the signals, but some ten meters of twisted wire should always be OK (I use 3m
  383. of screened audio cable for file transfer purposes, and it works fine. Not
  384. that other kinds of wire wouldn't do; I took what I found). See a good book on
  385. transmission lines if you're interested in why long lines can be a problem.
  386.  
  387. This has been posted to comp.os.msdos.programmer by Andrew M. Langmead:
  388.  
  389.   The RS-232C spec. has an official limit of 50 ft for RS-232C cables.
  390.   Realistically they can be much longer.  The book "Managing UUCP and
  391.   Usenet" by O'Reilly and Associates has a table that they credit to
  392.   "Technical Aspects of Data Communications", by McNamara (Digital
  393.   Press, 1992). It lists the maximum distances for an RS-232C
  394.   connection.
  395.  
  396.   Baud Rate       | max distance      | max distance
  397.                   | shielded cable    | unshielded cable
  398.   ----------------------------------------------------------
  399.         110       |      5000ft       |     3000ft
  400.         300       |      5000ft       |     3000ft
  401.         1200      |      3000ft       |     3000ft
  402.         2400      |      1000ft       |     500ft
  403.         4800      |      1000ft       |     250ft
  404.         9600      |      250ft        |     250ft
  405.  
  406. Please note that "baud" is correct in this case, because we're speaking of
  407. the transmission line itself.
  408.  
  409. This is what Torbjoern (sp?) Lindgren told me:
  410.  
  411.   I have successfully transmitted at 115,200 with over 30m long cables!
  412.   And it wasn't especially good wires. I had some old telecables with 20
  413.   individual wires, and used 7 of them for transfer, and left the others
  414.   unconnected.
  415.  
  416.   I don't remember the exact length, but I know it was something over
  417.   30m, and it probably was closer to 40m than 30m. The unused lines
  418.   probably shielded the lines from each other or something like that.
  419.   The computers used were two PC-compatibles with off-the-shelf
  420.   com-ports. Nothing fancy.
  421.  
  422. Note that some serial ports are more critical with mutilated signals than
  423. others, so you just have to try and find out yourself what works.
  424.  
  425.  
  426.  
  427. Hardware
  428. ========
  429.  
  430.  
  431. The connectors
  432. --------------
  433.  
  434. PCs have 9pin/25pin male SUB-D connectors. The pin layout is as follows
  435. (seen from outside your PC):
  436.  
  437.         1                         13         1         5
  438.       _______________________________      _______________
  439.       \  . . . . . . . . . . . . .  /      \  . . . . .  /
  440.        \  . . . . . . . . . . . .  /        \  . . . .  /
  441.         ---------------------------          -----------
  442.         14                       25           6       9
  443.  
  444.  Name (V24)  25pin  9pin  Dir  Full name               Remarks
  445. --------------------------------------------------------------------------
  446.     TxD         2     3    o   Transmit Data           Data
  447.     RxD         3     2    i   Receive Data            Data
  448.     RTS         4     7    o   Request To Send         Handshaking
  449.     CTS         5     8    i   Clear To Send           Handshaking
  450.     DTR        20     4    o   Data Terminal Ready     Status
  451.     DSR         6     6    i   Data Set Ready          Status
  452.     RI         22     9    i   Ring Indicator          Status
  453.     DCD         8     1    i   Data Carrier Detect     Status
  454.     GND         7     5    -   Signal ground           Reference level
  455.      -          1     -    -   Protective ground       Don't use this one
  456.                                                        as signal ground!
  457.  
  458. The most important lines are RxD, TxD, and GND. Others are used with
  459. modems, printers and plotters to indicate internal states.
  460.  
  461. '1' ('mark', 'low') means -3v to -15v, '0' ('space', 'high') means +3v
  462. to +15v. On status lines, 'high' is the active state: status lines go to the
  463. positive voltage level to signal events.
  464.  
  465. The lines are:
  466.  
  467.   RxD, TxD: These lines carry the data; 1 is transmitted as 'mark' (what I
  468.     call 'low') and 0 is transmitted as 'space' ('high').
  469.  
  470.   RTS, CTS: Are used by the PC and the modem/printer/whatsoever (further
  471.     on referred to as the data set, or DCE) to start/stop a communication.
  472.     The PC sets RTS to 'high', and the data set responds with CTS 'high'.
  473.     (always in this order). If the data set wants to stop/interrupt the
  474.     communication (eg. imminent buffer overflow), it drops CTS to 'low';
  475.     the PC uses RTS to control the data flow.
  476.  
  477.   DTR, DSR: Are used to establish a connection at the very beginning, ie.
  478.     the PC and the data set 'shake hands' first to assure they are both
  479.     present. The PC sets DTR to 'high', and the data set answers with DSR
  480.     'high'. Modems often indicate hang-up by resetting DSR to 'low' (and
  481.     sometimes are hung up by dropping DTR).
  482.  
  483.   (These six lines plus GND are often referred to as '7 wire'-connection or
  484.   'hand shake'-connection.)
  485.  
  486.   DCD: The modem uses this line to indicate that it has detected the
  487.     carrier of the modem on the other side of the phone line. The signal is
  488.     rarely used by the software.
  489.  
  490.   RI: The modem uses this line to signal that 'the phone rings' (even if
  491.     there is neither a bell fitted to your modem nor a phone connected :-).
  492.  
  493.   GND: The 'signal ground', ie. the reference level for all signals.
  494.  
  495.   Protective ground: This line is connected to the power ground of the
  496.     serial adapter. It should not be used as a signal ground, and it
  497.     MUST NOT be connected to GND (even if your DMM [Digital MultiMeter] shows
  498.     up an ohmic connection!). Connect this line to the screen of the lead (if
  499.     there is one). Connecting protective ground on both sides makes sure that
  500.     no large currents flow thru' GND in case of an insulation defect on one
  501.     side (hence the name).
  502.  
  503. Technical data (typical values for PCs):
  504.  
  505.   Signal level: -10.5v/+11v
  506.   Short circuit current: 6.8ma
  507.   Output impedance: ca 2 kiloohms (non-linear!)
  508.   Input impedance: ca 4.3 kiloohms (non-linear!)
  509.  
  510.  
  511. Other asynchronous hardware than RS-232C
  512. ----------------------------------------
  513.  
  514. There are several other standards that use the same chipset and protocol as
  515. RS-232C. RS-422 and the more robust (but compatible) version RS-485 (to name
  516. some) use two wires for every signal. The transmitters can usually be
  517. disabled and enabled by software, which makes it possible to use such
  518. equipment in a bus system (RX and TX part share the same lines). Despite
  519. >from the possibility to enable and disable the receiver/transmitter section
  520. of the port, they are fully compatible to existing RS-232C software if a
  521. compatible chipset is used.
  522.  
  523. It's not possible to connect eg. RS-232C to RS-485 without an appropriate
  524. interface.
  525.  
  526.  
  527. Connecting devices (or computers)
  528. ------------------
  529.  
  530. When you connect a data set or DCE (eg. a modem), use this connection:
  531.  
  532.         GND1    to    GND2
  533.         RxD1    to    RxD2
  534.         TxD1    to    TxD2
  535.         DTR1    to    DTR2
  536.         DSR1    to    DSR2
  537.         RTS1    to    RTS2
  538.         CTS1    to    CTS2
  539.         RI1     to    RI2
  540.         DCD1    to    DCD2
  541.  
  542. In other words, simply connect each pin of the first plug with the
  543. corresponding pin of the other. This can easily be done using a
  544. 25-wire ribbon cable and two crimp connectors.
  545.  
  546. When you connect another computer (or any other DTE, like a terminal), this
  547. is the wiring you need (it is called a "null modem" connection):
  548.  
  549.         GND1    to    GND2
  550.         RxD1    to    TxD2
  551.         TxD1    to    RxD2
  552.         DTR1    to    DSR2
  553.         DSR1    to    DTR2
  554.         RTS1    to    CTS2
  555.         CTS1    to    RTS2
  556.  
  557. If software wants it, connect DCD1 to CTS1 and DCD2 to CTS2.
  558.  
  559. If hardware handshaking is not needed, you can omit the status lines.
  560. Connect:
  561.  
  562.         GND1    to    GND2
  563.         RxD1    to    TxD2
  564.         TxD1    to    RxD2
  565.  
  566. Additionally, connect (if software needs it):
  567.  
  568.         RTS1    to    CTS1 & DCD1
  569.         RTS2    to    CTS2 & DCD2
  570.         DTR1    to    DSR1
  571.         DTR2    to    DSR2
  572.  
  573. You won't need long wires for these! :-)
  574.  
  575. Remember: the names DTR, DSR, CTS & RTS refer to the lines as seen from
  576. the DTE (your PC). This means that for your data set DTR & RTS are incoming
  577. signals and DSR & CTS are outputs! Modems, printers, plotters etc. are
  578. connected 1:1, ie. pin x to pin x.
  579.  
  580.  
  581. Base addresses & interrupts
  582. ---------------------------
  583.  
  584. Normally, the following list is correct for your PC; note however that
  585. if the BIOS can't find a port, it won't leave spaces in its port
  586. table, so if there is no UART at 0x3E8, the port at 0x2E8 will be
  587. called COM3 by DOS. Compare the section on logical vs. phyical names.
  588.  
  589.   Port Name   Base address    Int #  Int level (IRQ)
  590.  
  591.     COM1         0x3F8        0xC      4
  592.     COM2         0x2F8        0xB      3
  593.     COM3         0x3E8        0xC      4
  594.     COM4         0x2E8        0xB      3
  595.  
  596. In your programs, you should refer to the table in the BIOS data segment.
  597. This is an excerpt from Ralf Brown's interrupt list (the actual author
  598. of this section is Robin Walker):
  599.  
  600.   Format of BIOS Data Segment at segment 40h:
  601.   Offset Size Description
  602.    00h WORD Base I/O address of 1st serial I/O port, zero if none
  603.    02h WORD Base I/O address of 2nd serial I/O port, zero if none
  604.    04h WORD Base I/O address of 3rd serial I/O port, zero if none
  605.    06h WORD Base I/O address of 4th serial I/O port, zero if none
  606.         Note: Above fields filled in turn by POST as it finds serial
  607.         ports. POST never leaves gaps. DOS and BIOS serial device
  608.         numbers may be redefined by re-assigning these fields.
  609.  
  610. Please note that this table is not the bible and that the BIOS is not an
  611. evangelist (and I'm rather sceptical anyway :-). Your BIOS might not tell
  612. you the pure truth; if you get a zero it does not necessarily mean that
  613. there are no more serial ports available. Your programs should nevertheless
  614. have a look at the usual places for comm ports. See the "Programming" section
  615. for an example program that checks if a UART is installed at a given base
  616. address. Compare the "logical vs. physical names" section below.
  617.  
  618. Another good idea is writing a small program that's then run in the
  619. AUTOEXEC.BAT and that fills the empty fields in the table with the
  620. correct values. My Award BIOS fails to recognize my fourth port at
  621. 0x2E8, so I typed a few bytes (14 altogether) in the debugger that
  622. write 0x2E8 to 0040:0006 and wrote them to a .COM file called in the
  623. AUTOEXEC.BAT.
  624.  
  625. Also see the Programming section for a routine that detects the interrupt
  626. level/number that a UART uses. It's not a good idea to hard-code level
  627. 4 and 3; make it at least user configurable.
  628.  
  629. See the chapter "Multi-Port Serial Adapters" for further information.
  630.  
  631.  
  632. Logical vs. physical ports
  633. --------------------------
  634.  
  635. DOS users (like card manufacturers) tend to confuse logical and
  636. physical names. COM1, COM2, etc. are _logical_ names for the serial
  637. ports 0, 1, etc. found by the BIOS during POST (Power-On Self Test).
  638. The BIOS searches at four different I/O addresses for UARTS: 0x3F8,
  639. 0x2F8, 0x3E8, 0x2E8, in exactly this order. Every UART found has an
  640. entry in the comm port table at segment 0x40, offset 0. The BIOS
  641. manages up to four different UARTs, because the table has no more than
  642. four spaces. To make the confusion complete, Microsoft decided
  643. that DOS users wouldn't be comfortable with counting from zero, so
  644. they numbered the logical names of the comm ports from 1 to 4. Thus
  645. COM1 is the first UART found by the BIOS during POST, COM2 the second,
  646. and so on. Usually COM1 has 0x3F8 as base addresses, COM2 0x2F8 and so
  647. on, but that's not necessarily the case. Please do not use the logical
  648. DOS names when you really mean physical addresses. It is _not_
  649. possible to 'jumper a UART as COM3', at least not directly.
  650.  
  651.  
  652. The chipsets
  653. ------------
  654.  
  655. In PCs, serial communication is realized with a set of three chips
  656. (there are no further components needed! (I know of the need of address
  657. logic & interrupt logic ;-) )): a UART (Universal Asynchronous
  658. Receiver/Transmitter) and two line drivers. Normally, the 82450/16450/8250
  659. does the 'brain work' while the 1488 and 1489 drive the lines (they are
  660. level shifting inverters; the 1488 drives the outputs).
  661.  
  662. These chips are produced by many manufacturers; it's of no importance
  663. which letters are printed in front of the numbers (mostly NS for National
  664. Semiconductor). Don't regard the letters behind the number also (if it's not
  665. the 16550A or the 82C50A); they just indicate special features and packaging
  666. (Advanced, New, MILitary, bug fixes [see below] etc.) or classification.
  667. Letters in between the numbers (eg. 16C450) indicate technology (C=CMOS).
  668.  
  669. You might have heard that it is possible to replace the 16450 by a 16550A
  670. to improve reliability and reduce software overhead. This is only useful if
  671. your software is able to use the FIFO (first in-first out) buffer feature.
  672. The chips are fully pin-compatible except for two pins that are not used by
  673. any serial adapter card known to the author: pin 24 (CSOUT, chip select out)
  674. and pin 29 (NC, no internal connection). With the 16550A, pin 24 is -TXRDY
  675. and pin 29 is -RXRDY, signals that aren't needed (except for DMA access -
  676. but not in the PC) and that even won't care if they are shorted to +5V or
  677. ground. Therefore it should always be possible to simply replace the 16450
  678. by the 16550A - even if it's not always useful due to lacking software
  679. capabilities. IT IS DEFINITELY NOT NECESSARY FOR COMMUNICATION AT UP TO LOUSY
  680. 9600 BPS! These rates can easily be handled by any CPU, and the
  681. interrupt-driven communication won't slow down the computer substantially. But
  682. if you want to use high-speed transfer with or without using the interrupt
  683. features (ie. by 'polling'), or multitasking, or multiple channels 'firing' at
  684. the same time, or disk I/O during transmission, it is recommendable to use the
  685. 16550A in order to make transmission more reliable if your software supports
  686. it (see excursion some pages below).
  687.  
  688. There *are* differences between the 16550A, 16550AF, and 16550AFN. The 16550AF
  689. has one more timing parameter (t_RXI) specified that's concerned with the
  690. -RXRDY pin and that's of no importance in the PC. And the 16550AFN is the
  691. only one still believed to be free of bugs (see below). So the best choice for
  692. your PC is 16550AFN, but you are well off with the 16550AN, too. [Info from a
  693. posting of Jim Graham.]
  694.  
  695. Don't worry about the missing 'A' if you have chips named xxx16550 which are
  696. not from National Semiconductor (eg. UM16550). As long as the first example
  697. in the 'Programming' section tells you that it is a 16550A, everything is
  698. fine. I've never heard of non-NS 16550s with the FIFO bug (see below).
  699.  
  700.  
  701. How to detect which chip is used
  702. --------------------------------
  703.  
  704. This is really not difficult. The 8250 normally has no scratch register (see
  705. data sheet info below), the 16450/82450 has no FIFO, the 16550 has no working
  706. FIFO :-) and the 16550A performs alright. See the Programming section for
  707. an example program that detects which one is used in your PC.
  708.  
  709. Note that there _are_ versions of the 8250 that _do_ have a scratch register!
  710. It's rather impossible to distinguish them from the 16450, but then it's not
  711. necessary either... I know of the SAB 82C50 from Siemens and the UM8250B
  712. (from UMC, a taiwanese company with a globe symbol; thanks, Alfred, for
  713. helping me out with that). You won't find 8250s in fast computers however,
  714. because their bus timing is too slow.
  715.  
  716.  
  717. Data sheet information
  718. ----------------------
  719.  
  720. Some hardware information taken from the data sheet of National
  721. Semiconductor (shortened and commented):
  722.  
  723. Pin description of the 16450 (16550A) [Dual-In-Line package]:
  724.  
  725.                    +-----+ +-----+
  726.                D0 -|  1  +-+   40|- VCC
  727.                D1 -|  2        39|- -RI
  728.                D2 -|  3        38|- -DCD
  729.                D3 -|  4        37|- -DSR
  730.                D4 -|  5        36|- -CTS
  731.                D5 -|  6        35|- MR
  732.                D6 -|  7        34|- -OUT1
  733.                D7 -|  8        33|- -DTR
  734.              RCLK -|  9        32|- -RTS
  735.               SIN -| 10        31|- -OUT2
  736.              SOUT -| 11        30|- INTR
  737.               CS0 -| 12        29|- NC (-RXRDY)
  738.               CS1 -| 13        28|- A0
  739.              -CS2 -| 14        27|- A1
  740.          -BAUDOUT -| 15        26|- A2
  741.               XIN -| 16        25|- -ADS
  742.              XOUT -| 17        24|- CSOUT (-TXRDY)
  743.               -WR -| 18        23|- DDIS
  744.                WR -| 19        22|- RD
  745.               VSS -| 20        21|- -RD
  746.                    +-------------+
  747.  
  748. Note: The status signals are negated compared to the port! If you write a
  749. '1' to the appropriate register bit, the pin goes 'low' (to ground level).
  750. On its way to the port, the signal is inverted again; this means that the
  751. status line at the port goes 'high' if you write a '1'. The same is true
  752. for inputs: you get a '1' from the register bit if the line at the port is
  753. 'high'. SIN and SOUT are inverted, too. (negative voltage at the port
  754. means +5v at the UART).
  755.  
  756. A0, A1, A2, Register Select, Pins 26-28:
  757. Address signals connected to these 3 inputs select a UART register for
  758. the CPU to read from or to write to during data transfer. A table of
  759. registers and their addresses is shown below. Note that the state of the
  760. Divisor Latch Access Bit (DLAB), which is the most significant bit of the
  761. Line Control Register, affects the selection of certain UART registers.
  762. The DLAB must be set high by the system software to access the Baud
  763. Generator Divisor Latches. [I'm sorry, but it's called that way even if it's
  764. a bps rate generator... :-)]. 'x' means don't care.
  765.  
  766.   DLAB  A2  A1  A0    Register
  767.     0    0   0   0    Receive Buffer (read) Transmitter Holding Reg. (write)
  768.     0    0   0   1    Interrupt Enable
  769.     x    0   1   0    Interrupt Identification (read)
  770.     x    0   1   0    FIFO Control (write) [undefined with the 16450. CB]
  771.     x    0   1   1    Line Control
  772.     x    1   0   0    Modem Control
  773.     x    1   0   1    Line Status
  774.     x    1   1   0    Modem Status
  775.     x    1   1   1    Scratch [special use on some boards. CB]
  776.     1    0   0   0    Divisor Latch (LSB)
  777.     1    0   0   1    Divisor Latch (MSB)
  778.  
  779. -ADS, Address Strobe, Pin 25: The positive edge of an active Address
  780. Strobe (-ADS) signal latches the Register Select (A0, A1, A2) and Chip
  781. Select (CS0, CS1, -CS2) signals.
  782. Note: An active -ADS input is required when Register Select and Chip
  783. Select signals are not stable for the duration of a read or write
  784. operation. If not required, tie the -ADS input permanently low. [As it is
  785. done in your PC. CB]
  786.  
  787. -BAUDOUT, Baud Out, Pin 15: This is the 16x clock signal from the
  788. transmitter section of the UART. The clock rate is equal to the main
  789. reference oscillator frequency divided by the specified divisor in the
  790. Baud Generator Divisor Latches. The -BAUDOUT may also be used for the
  791. receiver section by tying this output to the RCLK input of the chip. [Yep,
  792. that's true for your PC. CB].
  793.  
  794. CS0, CS1, -CS2, Chip Select, Pins 12-14: When CS0 and CS1 are high and CS2
  795. is low, the chip is selected. This enables communication between the UART
  796. and the CPU.
  797.  
  798. -CTS, Clear To Send, Pin 36: When low, this indicates that the modem or
  799. data set is ready to exchange data. This signal can be tested by reading
  800. bit 4 of the MSR. Bit 4 is the complement of this signal, and Bit 0 is '1'
  801. if -CTS has changed state since the previous reading (bit0=1 generates an
  802. interrupt if the modem status interrupt has been enabled).
  803.  
  804. D0-D7, Data Bus, Pins 1-8: Connected to the data bus of the CPU.
  805.  
  806. -DCD, Data Carrier Detect, Pin 38: blah blah blah, can be tested by
  807. reading bit 7 / bit 3 of the MSR. Same text as -CTS.
  808.  
  809. DDIS, Driver Disable, Pin 23: This goes low whenever the CPU is reading
  810. data from the UART. It can be used to control bus arbitrary logic.
  811.  
  812. -DSR, Data Set Ready, Pin 37: blah, blah, blah, bit 5 / bit 1 of MSR.
  813.  
  814. -DTR, Data Terminal Ready, Pin 33: can be set active low by programming
  815. bit 0 of the MCR '1'. Loop mode operation holds this signal in its
  816. inactive state.
  817.  
  818. INTR, Interrupt, Pin 30: goes high when an interrupt is requested by the
  819. UART. Reset low by the MR.
  820.  
  821. MR, Master Reset, Pin 35: Schmitt Trigger input, resets internal registers
  822. to their initial values (see below).
  823.  
  824. -OUT1, Out 1, Pin 34: user-designated output, can be set low by
  825. programming bit 2 of the MCR '1' and vice versa. Loop mode operation holds
  826. this signal inactive high. [Not used in the PC. CB]
  827.  
  828. -OUT2, Out 2, Pin 31: blah blah blah, bit 3, see above. [Used in your PC to
  829. connect the UART to the interrupt line of the slot when '1'. CB]
  830.  
  831. RCLK, Receiver Clock, Pin 9: This input is the 16x bps rate clock for
  832. the receiver section of the chip. [Normally connected to -BAUDOUT, as in
  833. your PC. CB]
  834.  
  835. RD, -RD, Read, Pins 22 and 21: When RD is high *or* -RD is low while the
  836. chip is selected, the CPU can read data from the UART. [One of these is
  837. normally tied. CB]
  838.  
  839. -RI, Ring Indicator, Pin 39: blah blah blah, Bit 6 / Bit 2 of the MSR.
  840. [Bit 2 only indicates change from active low to inactive high! Curious,
  841. isn't it? CB]
  842.  
  843. -RTS, Request To Send, Pin 32: blah blah blah, see DTR (Bit 1).
  844.  
  845. SIN, Serial Input, Pin 10.
  846.  
  847. SOUT, Serial Output, Pin 11.
  848.  
  849. -RXRDY, -TXRDY: refer to NS data sheet. These pins are used for DMA
  850. channeling. Since they are not connected in your PC, I won't describe them
  851. here.
  852.  
  853. VCC, Pin 40, +5v
  854.  
  855. VSS, Pin 20, GND
  856.  
  857. WR, -WR: same as RD, -RD for writing data.
  858.  
  859. XIN, XOUT, Pins 16 and 17: Connect a crystal here (1.5k betw. xtal & pin 17)
  860. and pin 16 with a capacitor of approx. 20p to GND and other xtal conn. 40p
  861. to GND. Resistor of approx. 1meg parallel to xtal. Or use pin 16 as an input
  862. and pin 17 as an output for an external clock signal of up to 8 MHz.
  863.  
  864.  
  865. Absolute Maximum Ratings:
  866.  
  867.   Temperature under bias: 0 C to +70 C
  868.   Storage Temperature: -65 C to 150 C
  869.   All input or output voltages with respect to VSS: -0.5v to +7.0v
  870.   Power dissipation: 1W
  871.  
  872. Further electrical characteristics see the very good data sheet of NS.
  873.  
  874.  
  875. UART Reset Configuration
  876.  
  877. Register/Signal        Reset Control      Reset State
  878. --------------------------------------------------------------------
  879.   IER                       MR            0000 0000
  880.   IIR                       MR            0000 0001
  881.   FCR                       MR            0000 0000
  882.   LCR                       MR            0000 0000
  883.   MCR                       MR            0000 0000
  884.   LSR                       MR            0110 0000
  885.   MSR                       MR            xxxx 0000 (according to signals)
  886.   SOUT                      MR            high (neg. voltage at the port)
  887.   INTR (RCVR errs)     Read LSR/MR        low
  888.   INTR (data ready)    Read RBR/MR        low
  889.   INTR (THRE)          Rd IIR/Wr THR/MR   low
  890.   INTR (modem status)  Read MSR/MR        low
  891.   -OUT2                     MR            high
  892.   -RTS                      MR            high
  893.   -DTR                      MR            high
  894.   -OUT1                     MR            high
  895.   RCVR FIFO           MR/FCR1&FCR0/DFCR0  all bits low
  896.   XMIT FIFO           MR/FCR1&FCR0/DFCR0  all bits low
  897.  
  898.  
  899.  
  900. Known problems with several chips
  901. ---------------------------------
  902.  
  903. (From material Madis Kaal received from Dan Norstedt and stuff Erik Suurmaa
  904. sent me)
  905.  
  906.     8250 and 8250-B:
  907.  
  908.         * These UARTs pulse the INT line after each interrupt cause has
  909.           been serviced (which none of the others do). [Generates interrupt
  910.           overhead. CB]
  911.  
  912.         * The start bit is about 1 us longer than it ought to be. [This
  913.           shouldn't be a problem. CB]
  914.  
  915.         * 5 data bits and 1.5 stop bits doesn't work.
  916.  
  917.         * When a 1 is written to the bit 1 (Tx int enab) in the IER,
  918.           a Tx interrupt is generated. This is an erroneous interrupt
  919.           if the THRE bit is not set. [So don't set this bit as long as
  920.           the THRE bit isn't set. CB]
  921.  
  922.         * The first valid Tx interrupt after the Tx interrupt is enabled
  923.           is probably missed. Suggested workaround:
  924.           1) Wait for the THRE bit to become set.
  925.           2) Disable CPU interrupts. [?]
  926.           3) Write Tx interrupt enable to the IER.
  927.           4) Write Tx interrupt enable to the IER again.
  928.              [Don't ask me why. I don't think it's necessary. CB]
  929.           5) Enable CPU interrupts.  [?]
  930.  
  931.         * The TEMT (bit 6) doesn't work properly.
  932.  
  933.         * If both the Rx and Tx interrupts are enabled, and a Rx interrupt
  934.           occurs, the IIR indication of the Tx interrupt may be lost.
  935.           Suggested workarounds:
  936.           1) Test THRE bit in the Rx routine, and either set IER bit 1
  937.              or call the Tx routine directly if it is set.
  938.           2) Test the THRE bit instead of using the IIR for Tx.
  939.  
  940.         [If one of these chips vegetates in your PC, go get your solder
  941.         iron heated... CB]
  942.  
  943.     8250A, 82C50A, 16450 and 16C450:
  944.  
  945.         * (Same problem as above:)
  946.           If both the Rx and Tx interrupts are enabled, and a Rx interrupt
  947.           occurs, the IIR indication may be lost; Suggested workarounds:
  948.           1) Test THRE bit in the Rx routine, and either set IER bit 1
  949.              or call the Tx routine directly if it is set.
  950.           2) Test the THRE bit instead of using the IIR.
  951.           3) [Don't enable both interrupts at the same time. CB]
  952.           4) [Replace the chip by a 16550AFN; it has this bug fixed. CB]
  953.  
  954.     16550 (without the A):
  955.  
  956.         * Rx FIFO bug: Sometimes the FIFO will get extra characters.
  957.           [This seemed to be very embarrassing for NS; they've added a
  958.           simple detection method for the 16550A (bit 6 of IIR). CB]
  959.  
  960.     16550 AF
  961.  
  962.         * When the TX FIFO is enabled, a character loss can appear if
  963.           the CPU writes a byte into the THR while the last one is still
  964.           in the shift register (not completely sent). [This is documented
  965.           by National Semiconductor; I've never experienced that, but that
  966.           might be because I've never seen a 16550 AF :) CB]
  967.  
  968.         * Terence Edwards reports that his RS485 adapter with 16550 AF
  969.           chips and a 16 MHz xtal gets parity bits wrong at 512 kbps; not
  970.           very astonishing I'd say because the chip is only guaranteed to
  971.           operate at 256kbps, with an 8 MHz xtal, and parity generators are
  972.           rather slow circuits.
  973.  
  974.  
  975. No 16550 AFN bugs reported (yet?)
  976.  
  977. [Same is true for the 16552, a two-in-one version of the 16550AFN, and the
  978. 16554, a quad-in-one version. CB]
  979.  
  980. You might call this a bug, though: in FIFO mode, THRE (bit 5 or LSR) is
  981. cleared when there is at least one character in the Tx FIFO, not if the
  982. FIFO can't take any more bytes; that's rather absurd, but that's the way
  983. it is.
  984.  
  985. A very solid method of handling the UART interrupts that avoids all possible
  986. int failures has been suggested by Richard Clayton, and I recommend it as
  987. well. Let your interrupt handler do the following:
  988.   1. Disarm the UART interrupts by masking them in the IMR of the ICU.
  989.   2. Send a specific or an unspecific EOI to the ICU (first slave, then
  990.      master, if you're using channels above 7).
  991.   3. Enable CPU interrupts (STI) to allow high priority ints to be processed.
  992.   4. Read IIR and follow its contents until bit 0 is set.
  993.   5. Check if transmission is to be kicked (when XON received or if CTS
  994.      goes high); if yes, call tx interrupt handler manually.
  995.   6. Disable CPU interrupts (CLI).
  996.   7. Rearm the UART interrupts by unmasking them in the IMR of the ICU.
  997.   8. Return from interrupt.
  998. This way you can arm all four UART ints at initialization time without
  999. having to worry about stuck interrupts. Start transmission by simply calling
  1000. the tx interrupt handler after you've written characters to the tx fifo of
  1001. your program.
  1002.  
  1003. If you need details about programming the ICU, refer to Chris Hall's
  1004. document about the 8259 that's available from my archive.
  1005.  
  1006.  
  1007. [... continued ...]
  1008.  
  1009. --
  1010. Chris Blum <chris@phil.uni-sb.de>  http://www.phil.uni-sb.de/~chris/
  1011.  
  1012.